package com.njtoyo.netrides.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.taxi.entity.json.PointCustomerSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
import org.geolatte.geom.Point;

import javax.persistence.*;
import java.util.Date;

/**
 * 实时单叫单表
 */
@Entity
@Table(name = "realtime_call")
@Accessors(chain = true)
@Data
public class RealtimeCall {

    /**
     * 主键
     */
    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 乘客
     */
    @ManyToOne
    @JoinColumn(name = "customer_id")
    private User user;

    /**
     * 司机Id
     */
    private Long driverId;

    /**
     * 出发地坐标
     */
    @Column(columnDefinition = "geometry(Point,4326)")
    @JsonSerialize(using = PointCustomerSerializer.class)
    private Point origin;

    /**
     * 出发地名称
     */
    private String originName;

    /**
     * 起点详细路名
     */
    private String originPlaceName;

    /**
     * 目的地坐标
     */
    @Column(columnDefinition = "geometry(Point,4326)")
    @JsonSerialize(using = PointCustomerSerializer.class)
    private Point destination;

    /**
     * 目的地名称
     */
    private String destinationName;

    /**
     * 目的地详细地名
     */
    private String destinationPlaceName;

    /**
     * 地区表ID
     */
    private Long areaId;

    /**
     * 地区ID
     */
    private Long cantonId;

    /**
     * 实时单类型：0:realtime[正常实时单],1:assign[派单实时单]
     */
    @Enumerated
    private Znum.RealtimeCategory category;

    /**
     * 状态
     */
    @Enumerated
    private Znum.AppointmentPick state;

    /**
     * 加价
     */
    private Integer priceMarkup;

    /**
     * 创建时间
     */
    private Date createdAt;

    /**
     * 修改时间
     */
    @JsonIgnore
    private Date updatedAt;

    /**
     * 路程
     */
    private Integer distance;

    /**
     * 接驾时间
     */
    @JsonIgnore
    private Date pickUpTime;

    /**
     * 行程
     */
    @OneToOne
    @JoinColumn(name = "refId")
    @JsonIgnore
    private Ride ride;

    /**
     * 用户来源
     */
    @Enumerated
    private User.CustomerFrom platform;

    @Transient
    private String adCode;

    @Transient
    private Long realTimeCallId;

    @Transient
    private String originCoordinate;

    @Transient
    private String destinationCoordinate;

    @Transient
    private Long rideId;

}
